package cn.kgc.student.utils;
import java.io.Serializable;
import java.util.List;
public class Page implements Serializable {
	private int pageNo;
	private int pageSize = 15;
	private int totalCount;
	private int totalPageCount;
	private List list;
	/**
	 * 注意，该方法必须在setTotalCount()之后调用
	 */
	public int getPageNo() {
		if(pageNo>totalPageCount){
			pageNo = totalPageCount;
		}else if(pageNo<1){
			pageNo = 1;
		}
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public void setPageNo(String pageNo) {
		if(pageNo==null)
			pageNo="1";
		this.pageNo = Integer.parseInt(pageNo);
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
		this.totalPageCount = (totalCount-1)/pageSize+1;
	}
	public int getTotalPageCount() {
		return totalPageCount;
	}
	public void setTotalPageCount(int totalPageCount) {
		this.totalPageCount = totalPageCount;
	}
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}

	/**
	 * 获得当前页首行的下标(从0开始算)
	 */
	public int firstRow(){
		return (getPageNo()-1)*pageSize;
	}
	/**
	 * 获得当前页最后一行的下标(从1开始算)
	 */
	public int lastRow(){
		return getPageNo()*pageSize;		
	}


}
